// 致力于将所有的接口存储在同一个文件中

// ajax的二次封装
function request(url, attr, type = "get") {//向指定接口发送请求  返回一个promise实例
    return new Promise(function (resolve, reject) {
        $.ajax({
            type,
            url,
            data: {
                ...attr
            },
            datatype: "json",
            success: function (result) {
                resolve(result)//请求成功就返回数据
            },
            error: function (error) {
                reject(error)//请求失败=>返回错误
            }

        })
    })
}




const isexituser = attr => request("../php/resiter_user.php", attr)//p返回promise实例

const isexitphone = attr => request("../php/resiter_phone.php", attr)//p返回promise实例

const isexitemail = attr => request("../php/resiter_email.php", attr)//p返回promise实例

const registerjie = attr => request("../php/07register.php", attr, "post")//p返回promise实例

const login_account = attr => request("../php/login_account.php", attr, "post")//p返回promise实例

const login = attr => request("../php/login.php", attr, "post")//p返回promise实例

const search_order = attr => request("../php/search_order.php", attr)//p返回promise实例
const grade_delete = attr => request("../php/grade_delete.php", attr)//p返回promise实例
const grade_update = attr => request("../php/grade_update.php", attr, "post")//p返回promise实例
const search_one = attr => request("../php/search_one.php", attr)//p返回promise实例
const searchgoods = attr => request("../php/searchgoods_order.php", attr)//p返回promise实例
const goodssearchlist = attr => request("../php/goodssearchlist.php", attr)//p返回promise实例
const goodsziduan = attr => request("../php/goodsziduan.php", attr)//p返回promise实例
const addtoshopcar = attr => request("../php/addtoshopcar.php", attr, "post")//p返回promise实例
const searchshopcar = attr => request("../php/searchshopcar.php", attr, "post")//p返回promise实例
const goods_update = attr => request("../php/goods_update.php", attr)//p返回promise实例
const goods_delete = attr => request("../php/goods_delete.php", attr)//p返回promise实例



// function isexitphone(attr) {//{user:13131331,pwd:07150715}
//     return request("../php/resiter_phone.php", attr)
// }

// function isexitemail(attr) {//{user:13131331,pwd:07150715}
//     return request("../php/resiter_email.php", attr)
// }


// function registerjie(attr) {//{user:13131331,pwd:07150715}
//     return request("../php/07register.php", attr, "post")
// }

// function login(attr) {//{user:13131331,pwd:07150715}
//     return request("../php/login_account.php", attr, "post")
// }

